/** \file Allocator_t.cc 
 * Test definitions for the class Allocator.
 *
 * (C) Copyright 2003-2006 by Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: Allocator_t.cc 117 2006-06-19 06:49:41Z semihc $
 *
 *
 */


#include "Allocator.hpp"
#include "AllocDbg.hpp"
#include <vector>
#include "TestHarness.hh"
#include "HeapDbg.hh"


using namespace std;
using namespace TC;
using namespace TC::test;

TC_DEF_FILE("$Revision: 117 $");

namespace {

  struct A 
  {
    char c;
    int i;
    double d;
  };

}

namespace TC {
 namespace test {

  bool Allocator_test()
  {
    vector<int, Allocator<int> > v1(30);
    vector<A, Allocator<A> > v2(5);

    TC_TEST(v1.size()==30);
    TC_TEST(v2.size()==5);

    vector<int> v3(10);
    // This should fail to compile: v1 = v3;

    vector<int, Allocator<int> > v4;
    v1 = v4;
    TC_TEST(v1.empty());

 
    HeapDbg hd;
    hd.resetStats();
    { 
      vector<int, AllocDbg<int> > v5;
      for(unsigned i=0; i<1000; ++i)
        v5.push_back(i);
      //char* p = (char*) ::operator new(sizeof(char)*1000, hd);
      //::operator delete[](p, hd);
    }
    hd.printStats();

    return true;
  }

  
 } // end namespace
} // end namespace



